package com.lyl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyl.mapper.UserAuthInfoMapper;
import com.lyl.domain.UserAuthInfo;
import com.lyl.service.UserAuthInfoService;

import javax.security.auth.callback.LanguageCallback;
import java.util.Collections;
import java.util.List;


/**
 * @author lylbell
 * @date 2021-06-26 14:44
 */
    
@Service
public class UserAuthInfoServiceImpl extends ServiceImpl<UserAuthInfoMapper, UserAuthInfo> implements UserAuthInfoService{

    /**
     * 通过用户id去查询用户认证信息
     *
     * @param id
     * @return
     */
    @Override
    public List<UserAuthInfo> getAuthInfoByUserId(Long id) {
        List<UserAuthInfo> list = list(new LambdaQueryWrapper<UserAuthInfo>().eq(UserAuthInfo::getUserId, id));
        return list == null ? Collections.emptyList():list;//处理null的情况
    }



    /**
     * 通过认证唯一标识查询用户认证信息
     *
     * @param authCode
     * @return
     */
    @Override
    public List<UserAuthInfo> getAuthInfoByAuthCode(Long authCode) {
        return list(new LambdaQueryWrapper<UserAuthInfo>().eq(UserAuthInfo::getAuthCode,authCode));
    }
}
